<template>
  <div class="Alert">
    <div class="box">
      <div class="content">
        <h3>修改用户信息</h3>
        <p>
          <span>用户名称:</span>
          <input type="text" :placeholder="groupItem.uname" ref="uname" />
        </p>
        <p>
          <span>微信号:</span>
          <input type="text" :placeholder="groupItem.wx" ref="wx" />
        </p>
        <p>
          <span>手机号:</span>
          <input type="text" :placeholder="groupItem.phone" ref="phone" />
        </p>
        <p>
          <span>性别:</span>
          <select ref="sex">
            <option value="男" :selected="groupItem.sex === '男'">男</option>
            <option value="女" :selected="groupItem.sex === '女'">女</option>
          </select>
        </p>
        <p>
          <span>身份:</span>
          <select ref="identity">
            <option value="群众" :selected="groupItem.identity === '群众'">
              群众
            </option>
            <option value="党员" :selected="groupItem.identity === '党员'">
              党员
            </option>
          </select>
        </p>
        <p>
          <span>状态:</span>
          <select ref="state">
            <option value="开启" :selected="groupItem.state === '启用'">
              启用
            </option>
            <option value="停用" :selected="groupItem.state === '停用'">
              停用
            </option>
          </select>
        </p>
        <p>
          <button @click="confirm(groupItem.id)">确认</button>
          <button @click="cancel">取消</button>
        </p>
      </div>
    </div>
  </div>
</template>

<script>
import * as API from "../../../api/getdata";
export default {
  // import引入的组件需要注入到对象中才能使用
  components: {},
  props: ["isShow", "groupItem"],
  model: {
    prop: "isShow",
    event: "close",
  },
  data() {
    // 这里存放数据
    return {
      name: "",
      nowdata: "",
    };
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 方法集合
  mount: {},
  methods: {
    confirm(id) {
      API.editUser({
        id: id,
        uname: this.$refs["uname"].value
          ? this.$refs["uname"].value
          : this.groupItem.uname,
        wx: this.$refs["wx"].value ? this.$refs["wx"].value : this.groupItem.wx,
        phone: this.$refs["phone"].value
          ? this.$refs["phone"].value
          : this.groupItem.phone,
        sex: this.$refs["sex"].value === "男" ? "0" : "1",
        identity: this.$refs["identity"].value,
        state: this.$refs["state"].value,
      });
      API.getUser().then((res) => {
        this.subscribeList = res;
      });
      this.$emit("close", !this.isShow);
    },
    cancel() {
      this.$emit("close", !this.isShow);
    },
  },
};
</script>
<style scoped>
.Alert {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.2);
}
.box {
  width: 675px;
  height: 568px;
  background-color: #fff;
  position: absolute;
  top: 15%;
  left: calc(50% - 678px / 2);
  display: flex;
  justify-content: center;
  align-items: center;
}
.content {
  widows: 70%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}
.content > h3 {
  text-align: center;
}
.content > p {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.content > p > input {
  width: 291px;
  height: 40px;
  outline: none;
  border: none;
  border: 1px solid #5597f9;
  margin: 0 10px;
  padding: 0 10px;
}
.content > p > select {
  width: 291px;
  height: 40px;
  outline: none;
  border: none;
  border: 1px solid #5597f9;
  margin: 0 10px;
  padding: 0 10px;
}
.content > p > button {
  outline: none;
  border: none;
  width: 97px;
  height: 39px;
}
.content > p > button:first-child {
  background-color: #3894ff;
  border: 1px solid #3894ff;
  color: #fff;
}
.content > p > button:last-child {
  background-color: #fff;
  border: 1px solid #000;
  color: #000;
}
</style>
